package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DsTollInfo;
import com.ruoyi.system.service.IDsTollInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 收费管理Controller
 *
 * @author ruoyi
 * @date 2024-06-14
 */
@RestController
@RequestMapping("/system/tollInfo")
public class DsTollInfoController extends BaseController
{
    @Autowired
    private IDsTollInfoService dsTollInfoService;

    /**
     * 查询收费管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:tollInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(DsTollInfo dsTollInfo)
    {
        startPage();
        List<DsTollInfo> list = dsTollInfoService.selectDsTollInfoList(dsTollInfo);
        return getDataTable(list);
    }

    /**
     * 导出收费管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:tollInfo:export')")
    @Log(title = "收费管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DsTollInfo dsTollInfo)
    {
        List<DsTollInfo> list = dsTollInfoService.selectDsTollInfoList(dsTollInfo);
        ExcelUtil<DsTollInfo> util = new ExcelUtil<DsTollInfo>(DsTollInfo.class);
        util.exportExcel(response, list, "收费管理数据");
    }

    /**
     * 获取收费管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:tollInfo:query')")
    @GetMapping(value = "/{tollId}")
    public AjaxResult getInfo(@PathVariable("tollId") Long tollId)
    {
        return success(dsTollInfoService.selectDsTollInfoByTollId(tollId));
    }

    /**
     * 新增收费管理
     */
    @PreAuthorize("@ss.hasPermi('system:tollInfo:add')")
    @Log(title = "收费管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DsTollInfo dsTollInfo)
    {
        return toAjax(dsTollInfoService.insertDsTollInfo(dsTollInfo));
    }

    /**
     * 修改收费管理
     */
    @PreAuthorize("@ss.hasPermi('system:tollInfo:edit')")
    @Log(title = "收费管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DsTollInfo dsTollInfo)
    {
        return toAjax(dsTollInfoService.updateDsTollInfo(dsTollInfo));
    }

    /**
     * 删除收费管理
     */
    @PreAuthorize("@ss.hasPermi('system:tollInfo:remove')")
    @Log(title = "收费管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{tollIds}")
    public AjaxResult remove(@PathVariable Long[] tollIds)
    {
        return toAjax(dsTollInfoService.deleteDsTollInfoByTollIds(tollIds));
    }
}
